home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / dos / setfilesize.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  97 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: setfilesize.c,v 1.2 1996/10/24 15:50:37 aros Exp $
  4.     $Log: setfilesize.c,v $
  5.     Revision 1.2  1996/10/24 15:50:37  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.1  1996/09/11 12:54:47  digulla
  9.     A couple of new DOS functions from M. Fleischer
  10.  
  11.     Desc:
  12.     Lang: english
  13. */
  14. #include <clib/exec_protos.h>
  15. #include <dos/dosextens.h>
  16. #include <dos/filesystem.h>
  17. #include "dos_intern.h"
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22.     #include <clib/dos_protos.h>
  23.  
  24.     AROS_LH3(LONG, SetFileSize,
  25.  
  26. /*  SYNOPSIS */
  27.     AROS_LHA(BPTR, file,   D1),
  28.     AROS_LHA(LONG, offset, D2),
  29.     AROS_LHA(LONG, mode,   D3),
  30.  
  31. /*  LOCATION */
  32.     struct DosLibrary *, DOSBase, 76, Dos)
  33.  
  34. /*  FUNCTION
  35.     Change the size of a file.
  36.  
  37.     INPUTS
  38.     file   - filehandle
  39.     offset - relative size
  40.     mode   - OFFSET_BEGINNING, OFFSET_CURRENT or OFFSET_END
  41.  
  42.     RESULT
  43.     New size of the file or -1 in case of an error.
  44.     IoErr() gives additional information in that case.
  45.  
  46.     NOTES
  47.  
  48.     EXAMPLE
  49.  
  50.     BUGS
  51.  
  52.     SEE ALSO
  53.  
  54.     INTERNALS
  55.  
  56.     HISTORY
  57.     29-10-95    digulla automatically created from
  58.                 dos_lib.fd and clib/dos_protos.h
  59.  
  60. *****************************************************************************/
  61. {
  62.     AROS_LIBFUNC_INIT
  63.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  64.  
  65.     /* Get pointer to filehandle */
  66.     struct FileHandle *fh=(struct FileHandle *)BADDR(file);
  67.  
  68.     /* Get pointer to process structure */
  69.     struct Process *me=(struct Process *)FindTask(NULL);
  70.  
  71.     /* Get pointer to I/O request. Use stackspace for now. */
  72.     struct IOFileSys io,*iofs=&io;
  73.  
  74.     /* Prepare I/O request. */
  75.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  76.     iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  77.     iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  78.     iofs->IOFS.io_Device =fh->fh_Device;
  79.     iofs->IOFS.io_Unit   =fh->fh_Unit;
  80.     iofs->IOFS.io_Command=FSA_READ;
  81.     iofs->IOFS.io_Flags  =0;
  82.     iofs->io_Args[0]=offset<0?-1:0;
  83.     iofs->io_Args[1]=offset;
  84.     iofs->io_Args[2]=mode;
  85.  
  86.     /* Send the request. */
  87.     DoIO(&iofs->IOFS);
  88.     
  89.     /* Set error code and return */
  90.     if((me->pr_Result2=iofs->io_DosError))
  91.         return -1;    
  92.     else
  93.         return iofs->io_Args[1];
  94.     
  95.     AROS_LIBFUNC_EXIT
  96. } /* SetFileSize */
  97.